home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok07 / m2tests / teststrings.mod < prev    next >
Text File  |  1993-11-04  |  3KB  |  81 lines

  1. (*********************************************************************
  2.  *                                                                   *
  3.  *  :Program.    TestStrings.mod                                     *
  4.  *  :Author.     Michael Frieß                                       *
  5.  *  :Address.    Kernerstr. 22a                                      *
  6.  *  :shortcut.   [MiF]                                               *
  7.  *  :Version.    1.0                                                 *
  8.  *  :Date.       30.09.88                                            *
  9.  *  :Copyright.  PD                                                  *
  10.  *  :Language.   Modula-II                                           *
  11.  *  :Translator. M2Amiga                                             *
  12.  *  :Contents.   Test of module Strings                              *
  13.  *                                                                   *
  14.  *********************************************************************)
  15.  
  16. MODULE TestStrings;
  17.  
  18. FROM Strings  IMPORT Compare;
  19. FROM InOut    IMPORT WriteInt, WriteString, WriteLn,
  20.                      OpenOutput, CloseOutput;
  21.  
  22. CONST Short = "String";
  23.  
  24. VAR   Long   : ARRAY [1..30] OF CHAR;
  25.       Result : INTEGER;
  26.  
  27. PROCEDURE TestCompare (VAR str: ARRAY OF CHAR;
  28.                        start, length: INTEGER;
  29.                        token: ARRAY OF CHAR;
  30.                        caseSens: BOOLEAN;
  31.                        expected: INTEGER);
  32.  VAR result: INTEGER;
  33.  BEGIN
  34.   WriteString (" PROCEDURE Compare"); WriteLn;
  35.   result := Compare (str, start, length, token, caseSens);
  36.   WriteString ("  str    = "); WriteString (str);    WriteLn;
  37.   WriteString ("  start  = "); WriteInt (start,  4); WriteLn;
  38.   WriteString ("  length = "); WriteInt (length, 4); WriteLn;
  39.   WriteString ("  token  = "); WriteString (token);  WriteLn;
  40.   WriteString ("  caseS. = ");
  41.    IF caseSens THEN
  42.     WriteString ("TRUE")
  43.    ELSE
  44.     WriteString ("FALSE")
  45.    END;
  46.   WriteLn;
  47.   WriteLn;
  48.   WriteString ("  expect = "); WriteInt (expected, 4); WriteLn;
  49.   WriteString ("  result = "); WriteInt (result, 4); WriteLn;
  50.   IF result = expected THEN
  51.     WriteString (" result ist korrekt.")
  52.   ELSE
  53.     WriteString (" FEHLER!!")
  54.   END;
  55.   WriteLn;
  56.   WriteLn
  57.  END TestCompare;
  58.  
  59. BEGIN
  60.  WriteString ("Nur Enter-Taste eingeben für Ausgabe auf Bildschirm!");
  61.  WriteLn;
  62.  WriteString ("Name der Ausgabedatei ");
  63.  OpenOutput ("Errors");
  64.  WriteString ("Test des Moduls Strings"); WriteLn;
  65.  WriteLn;
  66.  WriteString (" V3.11d: Prozedur Compare berücksichtigt den");
  67.  WriteLn;
  68.  WriteString (" Parameter length nicht."); WriteLn;
  69.  Long := "String mit weiteren Zeichen";
  70.  TestCompare (Long, 0, 6, Long,  TRUE, 0);
  71.  TestCompare (Long, 0, 0, Long,  TRUE, 0);
  72.  TestCompare (Long, 0, 6, Short, TRUE, 0);
  73.  TestCompare (Long, 0, 5, Short, TRUE, 0);
  74.  TestCompare (Long, 0,10, Short, TRUE, -7);
  75.  Long := Short;
  76.  TestCompare (Long, 0, 6, Short, TRUE, 0);
  77.  CloseOutput;
  78.  WriteString ("Ende des Tests."); WriteLn
  79. END TestStrings.
  80.  
  81.